﻿@{
    ViewBag.Title = "用户管理";
    var collection = Request.QueryString;
}
@using MvcApplication.Entity
@using MvcApplication.Common
@model  PaginationResult<UserInfo>

<div class="am-cf am-padding">
    <div class="am-fl am-cf">
        <strong class="am-text-primary am-text-lg">用户管理</strong> / 
        <small>Member</small>
    </div>
</div>
<form>
    <div class="am-g">
        <div class="am-u-sm-12 am-u-md-3">
            <div class="am-form-group">
                <select data-am-selected="{btnsize: 'sm'}" name="status">
                    <option value="null">所有状态</option>
                    @foreach (var value in Enum.GetValues(typeof(UserStatus)))
                    {
                        <option value="@((int)value)" @Html.IsSelected(value, "status")>@value</option>
                    }
                </select>
            </div>
        </div>
        <div class="am-u-sm-12 am-u-md-3">
            <div class="am-form-group">
                <select data-am-selected="{btnsize: 'sm'}" name="gender">
                    <option value="null">所有性别</option>
                    @foreach (var value in Enum.GetValues(typeof(UserGender)))
                    {
                        <option value="@((int)value)" @Html.IsSelected(value, "gender")>@value</option>
                    }
                </select>
            </div>

        </div>
        <div class="am-u-sm-12 am-u-md-6">
            <div class="am-input-group am-input-group-sm">
                <input type="text" class="am-form-field" placeholder="姓名或邮件" name="namemail" value="@Html.GetRequest("namemail")">
                <span class="am-input-group-btn">
                    <button class="am-btn am-btn-default" type="submit">搜索</button>
                </span>
            </div>
        </div>
    </div>
</form>
<div class="am-g">
    <div class="am-u-sm-12 am-u-md-6">
        <div class="am-btn-toolbar">
            <div class="am-btn-group am-btn-group-xs">
                <button type="button" class="am-btn am-btn-default" onclick="showNewUserModal();">
                    <span class="am-icon-plus"></span>&nbsp;新增
                </button>
                <button type="button" class="am-btn am-btn-default" onclick="location.reload()">
                    <span class="am-icon-archive"></span>&nbsp;刷新
                </button>
                <button type="button"
                    onclick="editUserStatus(@((int)UserStatus.禁止登陆))"
                    class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only">
                    <span class="am-icon-trash-o"></span>&nbsp;禁止登陆
                </button>
                <button type="button"
                    onclick="editUserStatus(@((int)UserStatus.正常))"
                    class="am-btn am-btn-default am-btn-xs am-text-success am-hide-sm-only">
                    <span class="am-icon-trash-o"></span>&nbsp;设为正常
                </button>
            </div>
        </div>
    </div>
</div>

<div class="am-g">
    <div class="am-u-sm-12">
        <form class="am-form" id="table-form">
            <table cellspacing="0" class="am-table am-table-striped am-table-hover table-main">
                <thead>
                    <tr>
                        <th>
                            <input type="checkbox" onchange="totalCheck(this)" /></th>
                        <th>ID</th>
                        <th>姓名</th>
                        <th>邮箱</th>
                        <th>性别</th>
                        <th>状态</th>
                        <th>新建日期</th>
                        <th>#操作</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var member in Model.Datas)
                    {
                        <tr>
                            <td>
                                <input type="checkbox" name="uids" value="@member.ID"/>
                            </td>
                            <td>@member.ID</td>
                            <td style="width: 350px;">
                                @member.FullName
                            </td>
                            <td>@member.Email</td>
                            <td>@member.Gender.ToString()</td>
                            <td>@member.Status.ToString()</td>
                            <td>@member.CreateAt.ToString("yyyy年MM月dd日 HH:mm")</td>
                            <td>
                                <a href="javascript:;" onclick="edit(@member.ID)">编辑</a>
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        </form>
        <div>
            @{Html.RenderPartial("~/Views/Common/Pagination.cshtml", Model);}
        </div>
    </div>
</div>


<!--新建用户表单-->
<div class="am-g" id="newUserModal" style="display: none; margin-top: 20px;">
    <div class="am-u-md-8 am-u-sm-centered">
        <form class="am-form" id="newUserInfo">
            <div class="am-form-group">
                <input name="email" type="email" placeholder="用户邮箱" required>
            </div>
            <div class="am-form-group">
                <input name="password" id="password" type="password" placeholder="用户密码" required minlength="6">
            </div>
            <div class="am-form-group">
                <input name="repeatPassword" type="password" placeholder="重复密码">
            </div>
            <div class="am-form-group">
                <input name="fullName" type="text" placeholder="用户姓名" minlength="2" maxlength="5" required>
            </div>
            <div class="am-form-group">

                <select data-am-selected="{btnsize: 'sm'}" name="gender">
                    @foreach (var value in Enum.GetValues(typeof(UserGender)))
                    {
                        <option value="@((int)value)">@value</option>
                    }
                </select>
            </div>
            <div id="alert" style="padding: 0 0 20px 0; visibility: hidden; color: red;">
            </div>
            <button type="submit" class="am-btn am-btn-primary am-btn-block">新建用户</button>
        </form>
    </div>
</div>
<!--新建用户表单 END-->

@Scripts.Render("~/Content/js/member/list.js")
